{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
{load href="__PLUGINS__layui/layui.js"}
{load href="__PLUGINS__layui/css/layui.css"}
<style type="text/css">
    #des,#des input{ width: 40px;text-align:center;}
    #id{ width: 78px; }
    .bs-checkbox{ width: 36px; height: 40px }
    .fixed-table-toolbar .columns,.fixed-table-toolbar .search{margin-left:0px; margin-top: 0px }
    #title span{ float: right; }
    .asdlkjasd{ background: #1ab394; color: #fff}
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
            {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="fixed-table-toolbar loadClick">
                        <a class="btn btn-default btn-outline {present name='shenhe'}{else /}asdlkjasd{/present}" href="{:url('words')}">全部</a>
                        <a class="btn btn-default btn-outline {present name='shenhe'}{eq name='shenhe' value='1'}asdlkjasd{/eq}{else /}{/present}" href="{:url('words',['shenhe'=>1])}">通过</a>
                        <a class="btn btn-default btn-outline {present name='shenhe'}{eq name='shenhe' value='0'}asdlkjasd{/eq}{/present}" href="{:url('words',['shenhe'=>0])}">审核</a>
                        <a class="btn btn-default btn-outline {present name='shenhe'}{eq name='shenhe' value='-1'}asdlkjasd{/eq}{/present}" href="{:url('words',['shenhe'=>-1])}">拒绝</a>
                    <div class="fixed-table-toolbar">
                        <form  method="get" action="">
                            <div class="pull-left search">
                                <div class="columns columns-right btn-group pull-left">
                                    <select class="form-control" name="search">
                                        <option value="content" {php}if(input('param.search')=='content'){echo "selected";}{/php}>内容</option>
                                        <option value="user_id" {php}if(input('param.search')=='user_id'){echo "selected";}{/php}>用户id</option>
                                    </select>
                                </div>
                                {php}
                                if(input('?param.name')){
                                {/php}
                                <div class="pull-right search">
                                    <a class="btn btn-w-m btn-link" href="{:url('words')}">返回列表</a>
                                </div>{php}
                                }
                                {/php}
                                <div class="pull-right search">
                                    <button style="border-radius:0px; border:1px solid #e5e6e7; border-left:0px" class="btn btn-default btn-outline" type="submit">搜索</button>
                                </div>
                                <div class="pull-right search">
                                    <input class="form-control input-outline" type="text"
                                           {php}
                                           if(input('?param.name')){
                                    if(input('param.name')){
                                    echo "value='".input('name')."'";
                                    }

                                    }
                                    {/php}
                                    name="name" placeholder="搜索">
                                </div>


                            </div>
                        </form>
                    </div>
                    <div class="example">
                        <form class="form-horizontal" method="post">
                            <table data-toggle="table">
                                <thead>
                                <tr>
                                    <th class="bs-checkbox"><input type="checkbox" id="delidAll"></th>
                                    <th data-align="center">id</th>
                                    <th data-align="center">用户</th>
                                    <th data-align="center">内容</th>
                                    <th data-align="center">添加时间</th>

                                    <th data-align="center">审核时间</th>
                                    <th data-align="center">审核人</th>
                                    <th data-align="center">状态</th>
                                    <th data-align="center">管理</th>
                                </tr>
                                </thead>
                                <tbody id="form">
                                {volist name="data" id="v"}
                                <tr id="id{$v.id}" class="class">
                                    <td id="delid" ><input name="delAll[]" type="checkbox" value="{$v.id}"></td>
                                    <td>{$v.id}</td>
                                    <td><a onClick="add('{:url('member/index',['search'=>'id','name'=>$v['user_id']])}')" style="color:#40BCF7">{:getname($v.user_id)}</a> <br > ({$v.user_id})</td>
                                    {eq name="v.channel" value="2"}
                                    <td>{$v.content}</td>
                                    {else}
                                    <td>
                                        <a href="__ROOT__{$v.content}" target="_blank">
                                            <img style="max-width:100px" src="__ROOT__{$v.content}"/>
                                        </a>
                                    </td>
                                    {/eq}
                                    <td>{$v.time}</td>

                                    <td>
                                        <span>{neq name="$v.shenhe_time" value="0"}{:date('Y-m-d H:i:s', $v.shenhe_time)}{/neq}</span>
                                    </td>
                                    <td>
                                        <span>{:_getAdminName($v.shenhe_admin_id)}</span>
                                    </td>
                                    <td>{if condition="$v.shenhe_state eq '0'"}<span style="color: #ed5565">审 核</span>{elseif condition="$v.shenhe_state eq '1'" /}<span style="color: #1ab394">通 过</span>{elseif condition="$v.shenhe_state eq '-1'" /}<span style="color: #ed5565">拒 绝</span> {/if}</td>
                                    <td>
                                            {switch name="$v.shenhe_state"}
                                            {case value="0"}
                                            <div onClick="shenhe({$v.id},'1')" class="btn btn-primary btn-xs dropdown-toggle">通过
                                            </div>
                                            <div onClick="shenhe({$v.id},'-1')" class="btn btn-warning btn-xs dropdown-toggle">拒绝
                                            </div>
                                            {/case}
                                            {/switch}
                                            <div onClick="del({$v.id})" class="btn btn-danger btn-xs dropdown-toggle">删除
                                            </div>
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </form>
                    </div>
                </div>
                <hr>
            </div>

            <div class="row row-lg">
                <div class="col-sm-6">
                    <a  class="btn btn-outline btn-default" onclick="plPass()">
                        批量通过
                    </a>
                    <div  class="btn btn-outline btn-default" onclick="alla('del')">
                        批量删除
                    </div>
                </div>
                <div class="col-sm-12 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}

<script type="text/javascript">

    $(document).ready(function(){
        $('#delidAll').click(function(){
            $('input[type=checkbox]').each(function(){
                var self=$(this);
                if(!self.prop('checked')){
                    self.prop('checked',true);
                }else{
                    self.prop('checked',false);
                }
            });
        })
    });

    function del(id){
        swal_del(id,"{:url('delWords')}")
    }
    //批量通过按钮操作
    function plPass(){
        //alert();return;
        var all = $(".form-horizontal").serialize();

        ajaxFun("post",'{:url("plPass")}',all,'json',function(ret){
            if(ret){
                swal_msg('操作成功', '', 0, 1)
            }
        })
    }
    //批量删除按钮操作
    function alla(){
        //alert();return;
        var all = $(".form-horizontal").serialize();

        ajaxFun("post",'{:url("delAllWords")}',all,'json',function(ret){
            if(ret){
                swal_msg('操作成功', '', 0, 1)
            }
        })
    }



    function shenhe(id,value){
        ajaxFun("post","{:url('shenheWords')}",{id:id,status:value},'json',function(ret){
            if(ret){
                if(ret.ret){
                    layer.msg(ret.ret)
                    window.location.reload()
                }else{
                    layer.msg(ret.err)
                }
            }else{
                swal_msg("错误",ret,"error");
            }
        })
    }
</script>
